package com.yjj.demo.aop.service;

import com.yjj.demo.aop.annotation.LogAspect;
import com.yjj.demo.aop.constants.OperationModule;
import com.yjj.demo.aop.constants.OperationType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.concurrent.atomic.AtomicInteger;

/**
 *
 *
 * @author yangjiajia
 * @time 2021/8/21 23:57
 */
@Service
public class TestService {

    private Logger logger = LoggerFactory.getLogger(TestService.class);

    private AtomicInteger num = new AtomicInteger();

    @LogAspect(module = OperationModule.TEST_ADD, type = OperationType.ADD)
    public String add(String code) {
        logger.info("增加");
        return String.format("%s_%d", code, num.getAndIncrement());
    }

    @LogAspect(module = OperationModule.TEST_GET, type = OperationType.QUERY)
    public String get() {
        return String.valueOf(num.getAndIncrement());
    }

    @LogAspect(module = OperationModule.TEST_GET, type = OperationType.QUERY)
    public void get1() {
        logger.info("test.....");
    }
}
